package com.xrz.controller;

import com.github.pagehelper.PageInfo;
import com.xrz.common.Result;
import com.xrz.pojo.FriendMsg;
import com.xrz.service.FriendMsgService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;


@Api(value = "好友聊天controller", tags = {"好友聊天操作接口"})
@RestController
@RequestMapping("/friendsMsg")
public class FriendMsgController {

    private final FriendMsgService friendMsgService;

    public FriendMsgController(FriendMsgService friendMsgService) {
        this.friendMsgService = friendMsgService;
    }

    //获取聊天记录
    @ApiOperation(value = "获取聊天记录20条")
    @GetMapping("/getMsg/{friendId}/{myId}/{page}")
    public Result<?> getMsg(@PathVariable Integer friendId, @PathVariable Integer page, @PathVariable Integer myId) {
        FriendMsg friendMsg = new FriendMsg();
        friendMsg.setFriendId(friendId);
        friendMsg.setMyId(myId);
        PageInfo<FriendMsg> friendMsgList = friendMsgService.getMsg(friendId, myId, page);
        return Result.success(friendMsgList);
    }


}
